<?

?><div class="cms_browse_heading">
	<div class="cms_browse_heading_label">
		<h1>Browse Users</h1>
	</div>
	<div class="cms_browse_addrecord">
<?

	//need to add permissions here.. to check that we can add users???
	//assume if we are admin that we can
	$addUrl =  '/cms/html/index.php?fileNo=9';
	print <<< EOD
		<a href="$addUrl"><img src="/cms/images/cnt_add_new_record.gif" /></a>
EOD;
?>
	</div>
</div>
<div id="cms_browse_topdivider" class="cms_browse_divider"></div>
<div id="cms_browse">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cms_browsetext">
       
                    <tr> 
                      <td class="contentlinks" width="45"><b><a class="contentlinks" href="/cms/html/index.php?fileNo=7&sorts=uid">Id</a></b></td>
                      <td class="contentlinks" width="50"><b><a class="contentlinks" href="/cms/html/index.php?fileNo=7&sorts=usertype">Type</a></b></td>
                      <td class="contentlinks" ><b><a class="contentlinks" href="/cms/html/index.php?fileNo=7&sorts=username">Name</a></b></td>
                      <td></td>                      
                      <td class="contentlinks" width="75"><b>Action</b></td>
                    </tr>
                    <?
                    $query = "SELECT user.uid, usertype.description AS usertype, user.username, user.usertype AS userusertype FROM user, usertype WHERE usertype.usertype=user.usertype";
                    $sorts = extractStringWithKeyFromArray("sorts", $_REQUEST);
                    if(isset($sorts) && $sorts != NULL && $sorts !="") {
                    	$query .= " Order by $sorts Asc ";
                    }
                    //echo $query;
    $db->executeQuery($query);                
	while(($row = $db->nextObject())){		

?>
                    <tr> 
                      <td class="contentlinks" colspan="5"><img src="/cms/images/greyline.gif" width="100%" height="7"></td>
                    </tr>
                    
                    <tr> 
                      <td class="contentlinks" width="45"> <? print($row->uid); ?> 
                      </td>
                      <td class="contentlinks" > 
<?
		print($row->usertype);			
?>
                      </td>
                      <td class="contentlinks" > 
<? 
		print($row->username); 
?> 
                      </td>
                      <td><img src="/cms/images/spacer.gif" width="1" height="20" /></td>
                      <td class="contentlinks" width="75"><? if(($authInfo->usertype == '0') && ($row->userusertype == '0')) { ?><a href="/cms/html/index.php?fileNo=9&uid=<? print($row->uid); ?>" class="contentlinks">Edit</a> 
                        / <a href="/cms/html/index.php?fileNo=11&uid=<? print($row->uid); ?>" class="contentlinks">Delete</a><? } elseif ($row->userusertype > '0') { ?><a href="/cms/html/index.php?fileNo=9&uid=<? print($row->uid); ?>" class="contentlinks">Edit</a> 
                        / <a href="/cms/html/index.php?fileNo=11&uid=<? print($row->uid); ?>" class="contentlinks">Delete</a><? } else { ?>&nbsp;<? } ?>
                      </td>                      
                    </tr>
                    <?
	}

?>      
                    <tr> 
                      <td class="contentlinks" colspan="5"><img src="/cms/images/greyline.gif" width="100%" height="7"></td>
                    </tr>
	</table>
</div>            